﻿
using Dapper;
using HBase;
using System;
using System.Data;
namespace hCommand {
    //一个任务完成则不允许执行删除任务
    public class LocAreaChangeEngine : AbsLocEngine {

        public int locId;
        public long areaId;
        public int activeStatus;
        //入库完成反馈
        protected override TransRes Execute(IDbConnection conn ,IDbTransaction tran) {
            CoreWhLoc loc = conn.GetById<CoreWhLoc>(locId ,tran);
            int moveGroup = loc.moveGroup;
            long oldAreaId = loc.areaId;
            String sql = "update Core_Wh_Loc set area_Id= @areaId,  Active_Status = @activeStatus where id=@locId ";
            if( activeStatus == -1 ) {
                sql = "update Core_Wh_Loc set area_Id= @areaId   where id=@locId ";
            }

            conn.Execute(sql ,new { locId ,areaId ,activeStatus });

            if( areaId != oldAreaId ) {//换库区了
                updateMoveGroup(conn ,tran ,oldAreaId ,moveGroup ,loc.craneId);
            }
            updateMoveGroup(conn ,tran ,areaId ,moveGroup ,loc.craneId);
            return new TransRes();
        }




    }
}
